package com.yingside.annotation.actionlistener;

import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class MyJFrame extends JFrame {

	private JPanel contentPane;
	
	@ActionListenerAnnotation(listener=ConfirmActionListener.class)
	private JButton btnConfirm = new JButton("确定");
	
	@ActionListenerAnnotation(listener=CancelActionListener.class)
	private JButton btnCancel = new JButton("取消");

	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MyJFrame frame = new MyJFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}


	public MyJFrame() throws IllegalArgumentException, IllegalAccessException, InstantiationException {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new FlowLayout());
		setContentPane(contentPane);
		
	
		ButtonActionListener.bind(this);
		
		
		contentPane.add(btnConfirm);
		contentPane.add(btnCancel);
		pack();
	}

}
